import uuid

from langchain.embeddings import init_embeddings
from langgraph.store.memory import InMemoryStore

if __name__ == '__main__':
    user_id = "1"
    namespace_for_memory = (user_id, "memories")
    store = InMemoryStore(
        index={
            "embed": init_embeddings("openai:text-embedding-3-small"),  # Embedding provider
            "dims": 1536,  # Embedding dimensions
            "fields": ["food_preference", "$"]  # Fields to embed
        }
    )

    memories = store.search(
        namespace_for_memory,
        query="What does the user like to eat?",
        limit=3  # Return top 3 matches
    )

    store.put(
        namespace_for_memory,
        str(uuid.uuid4()),
        {
            "food_preference": "I love Italian cuisine",
            "context": "Discussing dinner plans"
        },
        index=["food_preference"]  # Only embed "food_preferences" field
    )

    # Store without embedding (still retrievable, but not searchable)
    store.put(
        namespace_for_memory,
        str(uuid.uuid4()),
        {"system_info": "Last updated: 2024-01-01"},
        index=False
    )
